package com.useeinfo.oa.modules.inspection.thread;

import com.useeinfo.framework.sugar.tools.DateTimeUtils;
import com.useeinfo.framework.sugar.tools.StringConverters;
import com.useeinfo.oa.modules.inspection.biz.InspectionExecuteTimeBiz;
import com.useeinfo.oa.modules.inspection.biz.InspectionOrderBiz;
import com.useeinfo.oa.modules.inspection.entity.InspectionExecuteTime;
import com.useeinfo.oa.modules.threadUtil.ThreadUtils;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service("InsPlanSecheduled")
public class InsPlanSecheduled {

    private final static Logger logger = LoggerFactory.getLogger(InsPlanSecheduled.class);

    @Autowired
    private InspectionExecuteTimeBiz inspectionExecuteTimeBiz;
    @Autowired
    private InspectionOrderBiz inspectionOrderBiz;




    public void execute() {
        logger.info("开始检查巡检计划表");
        List<InspectionExecuteTime> inspectionExecuteTimes = inspectionExecuteTimeBiz.createOrder(DateTimeUtils.formatDateToStringWithOnlyDate(new Date(), StringConverters.DATE_FORMAT_FULL));
        if (CollectionUtils.isNotEmpty(inspectionExecuteTimes)) {
            logger.info("查询出：{}", inspectionExecuteTimes.size());
            logger.info("开始进入线程");
            ThreadUtils.inspectionExecuteTimes(inspectionOrderBiz, inspectionExecuteTimes);
        }
    }


}
